package com.blog.controller.frontpage;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.blog.controller.base.BaseServlet;
import com.blog.dao.frontpage.ArticleDao;
import com.blog.entity.ArticleConstraintEntity;
import com.blog.entity.ArticleEntity;
import com.blog.entity.TypesEntity;
import com.blog.service.frontpage.ArticleService;
import com.blog.service.frontpage.IndexService;

@WebServlet("/index")
public class IndexServlet extends BaseServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//查询所有导航栏菜单分类
		IndexService indexService = new IndexService();
		List<TypesEntity> typesList = indexService.getAllTypesInfo();
		req.setAttribute("typesList",typesList);
		//查询首页所有文章推荐详情
		ArticleService articleService = new ArticleService();
		List<ArticleConstraintEntity> articleList = articleService.getAllArticleInfo();
		req.setAttribute("articleList", articleList);
		//查询首页所有热门推荐详情
		List<ArticleConstraintEntity> hotRecommendList = articleService.getHotRecommend();
		req.setAttribute("hotRecommendList",hotRecommendList );
		
		forward("llpfrontpage/index");
	}
}
